Ext.BLANK_IMAGE_URL = 'extjs3_1_1/resources/images/default/s.gif';
Ext.QuickTips.init();
if (!Ext.isIE) {
	Ext.util.CSS.swapStyleSheet('ext-patch','extjs3_1_1/resources/css/ext-patch.css');
}
Ext.ns('App.injury.Component');
Ext.ns('App.injury.Component.System');

//****************************************Panel
App.injury.Component.FWPanel = function(config){
	config = App.injury.Utils.doBorders(config);
	App.injury.Component.FWPanel.superclass.constructor.call(this, Ext.apply({},
			config || {}));
};

Ext.extend(App.injury.Component.FWPanel, Ext.Panel);	
Ext.reg('fwpanel', App.injury.Component.FWPanel);

// ****************************************Tree
App.injury.Component.FWTree = function(config) {
	config = App.injury.Utils.doBorders(config);
	App.injury.Component.FWTree.superclass.constructor.call(this, Ext.apply({
		autoScroll : true,
		useArrows:true
	},
			config || {}));
};
Ext.extend(App.injury.Component.FWTree, Ext.tree.TreePanel);
Ext.reg('fwtree', App.injury.Component.FWTree);

// ****************************************Grid
App.injury.Component.FWGrid = function(config) {
	config = App.injury.Utils.doBorders(config);
	App.injury.Component.FWGrid.superclass.constructor.call(this, Ext.apply({
		stripeRows:true,
		loadMask : true
	}, config || {}));
};
Ext.extend(App.injury.Component.FWGrid, Ext.grid.GridPanel, {});
Ext.reg('fwgrid', App.injury.Component.FWGrid);

//***********************************Form
App.injury.Component.FWForm = function(config) {
	App.injury.Component.FWForm.superclass.constructor.call(this, Ext.apply({
		border : false,
		labelWidth : 70,
		frame:false,
		labelAlign : 'right',
		bodyStyle : 'padding:5px 5px 0;border: 0px;'
	}, config || {}));
};
Ext.extend(App.injury.Component.FWForm, Ext.form.FormPanel, {});
Ext.reg('fwform', App.injury.Component.FWForm);

// ****************************************Window
App.injury.Component.FWWindow = function(config) {
	App.injury.Component.FWWindow.superclass.constructor.call(this, Ext.apply({
		closeAction : 'close',
		resizable : true,
		constrain : true,
		iconCls:'formWin',
		autoScroll:true,
		//animateTarget : Ext.getBody(),
		autoAction : true,
		modal : true
	}, config || {}));
};
Ext.extend(App.injury.Component.FWWindow, Ext.Window);
Ext.reg('fwwindow', App.injury.Component.FWWindow);


// ****************************************TabPanel
App.injury.Component.FWTabPanel = function(config) {
	config = App.injury.Utils.doBorders(config);
	App.injury.Component.FWTabPanel.superclass.constructor.call(this, Ext.apply({
	}, config || {}));
};
Ext.extend(App.injury.Component.FWTabPanel, Ext.TabPanel);
Ext.reg('fwtabpanel', App.injury.Component.FWTabPanel);


App.injury.Utils = {
		
		SKIN_COLOR : '#99BBE8',	
		doBorders:function(config){
			if(config){			
				var color = this.SKIN_COLOR;
				config.style = config.style?config.style:'';
				if(config.bottomBorder){
					config.style += 'border-bottom:1px solid '+color+';';
				}
				if(config.rightBorder){
					config.style += 'border-right:1px solid '+color+';';
				}
				if(config.topBorder){
					config.style += 'border-top:1px solid '+color+';';
				}
				if(config.leftBorder){
					config.style += 'border-left:1px solid '+color+';';
				}
			}
			return config;
		}
	};
Ext.Ajax.on('requestcomplete',function(action,response){
	var resText = response.responseText;
	if(resText.indexOf('success:false,errorMsg:') > 0){
		var error = eval('(' + resText + ')');
		Ext.Msg.show({
			title : '系统错误',
			msg : '发生错误,错误信息:'+error.errorMsg,
			buttons : Ext.MessageBox.OK,
			icon : Ext.MessageBox.ERROR
		});
		return;
	}
});